package com.jbookshelf.dal.enums;

import java.util.ArrayList;
import java.util.List;

public enum OrderState {
	NEW(0), REVIEWED(1), REJECTED(2), ACCEPTED(3), APPROVED(4), CANCELLED(5), PAID(6), RECIEVED(7), ENTERED(8), COMPLETED(9);
	 private final int index; 
	 private  OrderState(int i)
	 {
		 this.index=i;
	 }
	 public int index() { 
	        return index; 
	    }
	public List<OrderState> getAvaliableStates(OrderState state) {
		List<OrderState> list = new ArrayList<OrderState>();
		switch (state) {
		case NEW:
			list.add(OrderState.REVIEWED);
			list.add(OrderState.REJECTED);
			list.add(OrderState.ACCEPTED);
			list.add(OrderState.APPROVED);
			list.add(OrderState.CANCELLED);
			list.add(OrderState.PAID);
			list.add(OrderState.RECIEVED);
			list.add(OrderState.ENTERED);
			list.add(OrderState.COMPLETED);
			break;
		case REVIEWED:
			list.add(OrderState.REJECTED);
			list.add(OrderState.ACCEPTED);
			list.add(OrderState.APPROVED);
			list.add(OrderState.CANCELLED);
			list.add(OrderState.PAID);
			list.add(OrderState.RECIEVED);
			list.add(OrderState.ENTERED);
			list.add(OrderState.COMPLETED);
			break;
		case REJECTED:
			list.add(OrderState.COMPLETED);
			break;
		case ACCEPTED:
			list.add(OrderState.APPROVED);
			list.add(OrderState.CANCELLED);
			list.add(OrderState.PAID);
			list.add(OrderState.RECIEVED);
			list.add(OrderState.ENTERED);
			list.add(OrderState.COMPLETED);
			break;
		case APPROVED:
			list.add(OrderState.PAID);
			list.add(OrderState.RECIEVED);
			list.add(OrderState.ENTERED);
			list.add(OrderState.COMPLETED);
			break;
		case CANCELLED:
			list.add(OrderState.COMPLETED);
			break;
		case PAID:
			list.add(OrderState.RECIEVED);
			list.add(OrderState.ENTERED);
			list.add(OrderState.COMPLETED);
			break;
		case RECIEVED:
			list.add(OrderState.ENTERED);
			list.add(OrderState.COMPLETED);
			break;
		case ENTERED:
			list.add(OrderState.COMPLETED);
			break;
		default:
			break;
		}
		return list;
	}
}
